﻿var columns =
            [
                 { display: 'Key', name: 'key', type: 'text', hide: 1 },
                { display: '资源编码', name: 'Code', width: 100 },
                { display: '资源名称', name: 'Name', width: 120 },
                { display: '资源描述', name: 'Name', width: 200 }
             ];

//init controls
var manager;
$(document).ready(function () {
    initligerGrid();
    $("#btnSubmit").unbind("click").bind("click", selectResource);
});
function initligerGrid() {
    manager = null;
    manager = $("#permissionGrid").ligerGrid({
        columns: columns,
        title: '菜单类别',
        showTitle: true,
        width: '100%',
        enabledSort: true,
        height: '99%',
        rownumbers: true,
        //checkbox: true,
        url: "../Permission/GetJsonOfPermissions?rand="+Math.random()
    });
}

function dataReload()
{
   // initligerGrid();
}
//==================================只能选择一个
function selectResource() {
    var row = manager.getSelectedRow();
    if (!row) { $.ligerDialog.success('请选择根菜单行！'); return; }
    var permissionId= row["Key"].toString();
    var operationId = $("#hidOperationID").val();
    if (operationId == undefined || operationId.toString().length <= 0) { $.ligerDialog.success('异常无法操作！'); return; }
    $.get("../Operation/OperationPermission", { "operationId": operationId, "permissionId": permissionId }, function (data) {
        if (data == "ok") {
            $.ligerDialog.success('操作成功！');
            ajaxSubmitSuccess(); //公共类：提交成功后关闭当前窗口
        }
        else {
            $.ligerDialog.success('操作失败！');
        }
    });
}